import request from "@/utils/httpRequest";
import { AxiosPromise } from "axios";

import {
    TypeApparatusRoomVoQueryI,
    TypeRequirementPoolTablePageVoI,
} from "./current_status_apparatus_room_type";

/**
 * 获取需求库分页数据
 *
 * @param queryParams
 */
export function getApparatusRoomTablePage(
    queryParams?: TypeApparatusRoomVoQueryI
): AxiosPromise<TypeRequirementPoolTablePageVoI> {
    return request({
        url: "/api/v1/current_status_apparatus_room/page",
        method: "post",
        data: queryParams,
    });
}

/**
 * 获取需求库form数据
 *
 * @param queryParams
 */
export function getRequirementPoolFormVo(
    requirementPoolId: number
): AxiosPromise<TypeRequirementPoolTablePageVoI> {
    return request({
        url: "/api/v1/current_status_apparatus_room/" + requirementPoolId,
        method: "get",
    });
}

/**
 * 保存/更新需求库
 *
 * @param queryParams
 */
export function saveUpdateRequirementPool(
    queryParams?: TypeApparatusRoomVoQueryI
) {
    return request({
        url: "/api/v1/current_status_apparatus_room/update",
        method: "put",
        data: queryParams,
    });
}

/**
 * 下载导入模板
 *
 * @returns
 */
export function downloadTemplate() {
    return request({
        url: "/api/v1/current_status_apparatus_room/downloadTemplate",
        method: "get",
        responseType: "arraybuffer",
    });
}

/**
 * 导出筛选
 *
 * @param queryParams
 * @returns
 */
export function exportQuery(queryParams: TypeApparatusRoomVoQueryI) {
    return request({
        url: "/api/v1/current_status_apparatus_room/exportQuery",
        responseType: "arraybuffer",
        method: "post",
        data: queryParams,
    });
}

/**
 * 导出全部
 *
 * @param queryParams
 * @returns
 */
export function exportAll(period:string) {
    return request({
        url: "/api/v1/current_status_apparatus_room/exportAll",
        method: "get",
        params:{period},
        responseType: "arraybuffer",
    });
}

/**
 * 导入需求库
 *
 * @param file
 */
export function importExcel(file: File): AxiosPromise<TypeUploadResultGI> {
    const formData = new FormData();
    formData.append("file", file);
    return request({
        url: "/api/v1/current_status_apparatus_room/import",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//deleteByIdArray

/**
 * 删除由 idArray 组成的id 的记录
 *
 * @param queryParams
 */
export function deleteByIdArray(idList: number[]) {
    return request({
        url: "/api/v1/current_status_apparatus_room/delete",
        method: "post",
        data: idList,
    });
}

/**
 * 删除全部记录
 *
 * @param queryParams
 */
export function deleteAll(idList: number[]) {
    return request({
        url: "/api/v1/current_status_apparatus_room/delete_all",
        method: "get",
    });
}

export function calBbuRoomCountOfOccupied(period:string):AxiosPromise<number>{
    return request({
        url: "/api/v1/current_status_apparatus_room/cal_occupied_room_count",
        params:{period},
        method: "get",
    });
}


